﻿@model IEnumerable<TestSystem.Domain.Entities.Questions.Question>

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_adminLayout.cshtml";
}

<script type="text/javascript">
    $(function () {
        $(".RemoveLink").click(function () {
            var recordToDelete = $(this).attr("data-id");
            if (recordToDelete != '') {
                $.post("/Question/Remove", { "id": recordToDelete },
                    function (data) {
                            $('#row-' + data.DeleteId).fadeOut('slow');
                            $('#update-message').text(data.Message);
                            if(data.ItemCount == 0)
                                $('#questionTable').fadeOut('slow');
                                
                    });
            }
        });
    });
</script>

<h2>Zarządzaj pytaniami</h2>

<table class="hovered" id="questionTable">
    <tr>
        <th>
            ID
        </th>
        <th>
            Treść
        </th>
        <th>
            Rodzaj
        </th>
        <th>
            Poziom
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr id="row-@item.QuestionID">
        <td>
            @Html.DisplayFor(modelItem => item.QuestionID)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.QuestionText)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.QuestionType.Type)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Difficulty.DifficultyName)
        </td>
        <td>
            @Html.ActionLink("Edycja", "Edit", new { id=item.QuestionID }) |
           <a href="#" class="RemoveLink"data-id="@item.QuestionID">Usuń</a>
        </td>
    </tr>
}

</table>
